![]() |
PATH![]() |
After you have created a session, located the applet, and created an AWT context for the applet, you can instantiate it. An instantiated applet is defined by an
JMAppletViewerRef
object, and you use the
JMNewAppletViewer
function
JMNewAppletViewer
to create one.
Listing 1-11 shows an example of instantiating an applet.
Listing 1-11 Instantiating an applet
JMAppletSecurity securitySettings = {
kJMVersion, /* should be kJMVersion */
eAppletHostAccess, /* applet network access option */
eLocalAppletAccess, /* applet access to local file system */
true, /* restrict system.access packages */
true, /* restrict system.define packages */
true, /* restrict application.access packages */
true /* restrict application.define packages */
};
JMAppletViewerCallbacks viewerCallbacks = {
kJMVersion, /* should be kJMVersion */
MyShowDocument, /* showDocument callback */
MySetStatusMsg /* setMessage callback */
};
JMAppletViewerRef viewer;
err = JMNewAppletViewer(&viewer, context, locatorRef,
appletIndex, &securitySettings, &viewerCallbacks, 0);
/* reload the applet to get it going */
if (err == noErr) {
err = JMReloadApplet(viewer);
}
The JMNewAppletViewer function requires you to pass a security options data structure indicating the following security settings:
See Applet Security Structure for more information about using these flags.
If you want to determine the current security levels for a particular applet, you can use the
JMGetAppletViewerSecurity
function
JMGetAppletViewerSecurity
. To change existing security levels, you can use The
JMSetAppletViewerSecurity
function.
In addition, you must define two callbacks,
MyShowDocument
and
MySetStatusMsg
, when calling the
JMNewAppletViewer
function. The
MyShowDocument
function displays the contents of a URL passed back from the applet, and
MySetStatusMsg
displays any status messages the applet may pass to the application. You must also specify the index of the applet you want to instantiate (as returned by the
JMCountApplets
function
JMCountApplets
).
After you have instantiated the applet viewer object, you must load and execute the applet code by calling the function
JMReloadApplet
.
You can set or retrieve client data associated with the applet by using the functions
JMSetAppletViewerData
and
JMGetAppletViewerData
.
At any time you can stop execution of the applet by calling the
JMSuspendApplet
function
JMSuspendApplet
and resume it by calling the
JMResumeApplet
function
JMResumeApplet
. If you want to restart the applet without reloading it from the server, use The
JMRestartApplet
function.
When you are finished with an applet, you can dispose of it by calling the
JMDisposeAppletViewer
function
JMDisposeAppletViewer
. This function automatically halts applet execution and removes any frames associated with the applet.